<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>应用仿jQuery的attr方法设计横向选项卡</title>
<link rel="stylesheet" type="text/css" href="css/shopinfo.css" />
<link rel="stylesheet" type="text/css" href="css/public.css" />
<style>

</style>
<script type="text/javascript" >
function id(name){return document.getElementById(name);};
//获取和设置元素特性的值
function attr(elem,name,value){
  if( !name || name.constructor!=String ) return '';
  name = {'for':'htmlFor','class':'className'}[name]||name;
  if( typeof(value)!='undefined' ){
	  elem[name] = value;
	  if(elem.setAttribute) elem.setAttribute(name,value); }
  else if(value=='')
	  elem.removeAttribute(name);
  return elem[name] || elem.getAttribute(name) || '';
};

function switchtab(strObjName,intClkNum){
  var objName = id(strObjName);
  //==============================================
  if (!objName) return false;
  //==============================================
  var strTitTag = attr(objName,"titTag");
  var strConTag = attr(objName,"conTag");
  var intMaxNum = parseInt(attr(objName,"maxNum"));
  var intCurNum = parseInt(attr(objName,"curNum"));
  //==============================================
  if (intClkNum==intCurNum) return false;
  //==============================================
  var objTit,objCon;
  for (var i=1;i<=intMaxNum;i++){
	  try{
		  objTit = id(strTitTag+i.toString());
		  objCon = id(strConTag+i.toString());
		  if (i==intClkNum){
			  objTit.className = "on";
			  objCon.className = "on";
		  } else {
			  objTit.className = "of";
			  objCon.className = "of";
		  };
	  }catch(e){}
  };
  //==============================================
  attr(objName,"curNum",intClkNum);
};
</script>

</head>

<body>

-
</body>
</html>
